package com.zxbg.controller.systemtoolsController;

import com.zxbg.controller.Code;
import com.zxbg.controller.Result;
import com.zxbg.service.systemtoolsService.ApplySortService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/ApplySort")
public class ApplySortController {
    @Autowired
    ApplySortService applySortService;

    @GetMapping
    public Result getAllAppInCategory(@RequestHeader Integer tenant_id, @RequestHeader String employee_id) {
        return new Result(Code.GET_OK, applySortService.getAllAppInCategory(tenant_id, employee_id));
    }

    @PostMapping
    public Result getTargetCategoryApp(@RequestBody String key, @RequestHeader Integer tenant_id, @RequestHeader String employee_id) {
        return new Result(Code.GET_OK, applySortService.getTargetCategoryApp(key, tenant_id, employee_id));
    }

    @PutMapping
    public Result changeAppOrder(@RequestBody Map<String, String> map, @RequestHeader Integer tenant_id) {
        return new Result(Code.UPDATE_OK, applySortService.changeAppOrder(map.get("app_id"), Integer.parseInt(map.get("order")), tenant_id));
    }
}
